package nccloud.bs.cmp.informer;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import nc.bs.cmp.informer.validate.InformerSysFlagUtil;
import nc.bs.cmp.pub.IsExistRecordResultSetProcessor;
import nc.bs.dao.BaseDAO;
import nc.bs.framework.common.NCLocator;
import nc.bs.tmpub.pub.MapResultSetProcessor;
import nc.itf.cmp.transformbill.ITransformBillMaintainService;
import nc.jdbc.framework.SQLParameter;
import nc.md.persist.framework.IMDPersistenceQueryService;
import nc.pubitf.arap.gathering.IArapGatheringBillPubService;
import nc.pubitf.arap.pay.IArapPayBillPubService;
import nc.pubitf.cmp.changebill.ICmpChangeBillPubService;
import nc.pubitf.cmp.paybill.ICmpPayBillPubService;
import nc.pubitf.cmp.recbill.ICmpRecBillPubService;
import nc.pubitf.fts.commissiongathering.ICommissionGatherForInformerService;
import nc.pubitf.fts.commissionpayment.ICommissionPaymentForInformerService;
import nc.pubitf.org.IFundOrgPubService;
import nc.pubitf.sf.allocate.IAllocateForInformerService;
import nc.pubitf.sf.delivery.IDeliveryForInformerService;
import nc.vo.cmp.informer.GenerateFlagEnum;
import nc.vo.cmp.informer.InformerAppendVO;
import nc.vo.cmp.informer.InformerReleaseVO;
import nc.vo.cmp.informer.InformerVO;
import nc.vo.ml.NCLangRes4VoTransl;
import nc.vo.org.FundOrgVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.ISuperVO;
import nc.vo.pub.lang.UFBoolean;
import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDateTime;
import nc.vo.pub.lang.UFDouble;
import nc.vo.pubapp.AppContext;
import nc.vo.tmpub.datemanage.DateManageQueryVO;
import nc.vo.tmpub.initdate.CommInitDateCheck;
import nc.vo.tmpub.util.SqlUtil;
import nc.vo.tmpub.util.StringUtil;

public class NCCInformerBS {
	private IMDPersistenceQueryService mdQueryService;
	private static String modifier = "";

	public InformerAppendVO noGenerateBill(InformerVO vo) throws BusinessException {
		InformerAppendVO ret = new InformerAppendVO();
		InformerVO newvo = (InformerVO) this.getMDQueryService().queryBillOfVOByPK(InformerVO.class,
				vo.getPk_informer(), false);
		InformerSysFlagUtil.checkInformerOperSysFlag("NCC", new InformerVO[]{vo});
		if (!newvo.getTs().equals(vo.getTs())) {
			ret.setErrorMessage(NCLangRes4VoTransl.getNCLangRes().getStrByID("3607inf_0", "03607inf-0088"));
			return ret;
		} else if (!GenerateFlagEnum.HASNOGENERATE.getGenerateFlag().equals(newvo.getGenerateflag())) {
			ret.setErrorMessage(NCLangRes4VoTransl.getNCLangRes().getStrByID("3607inf_0", "03607inf-0103"));
			return ret;
		} else {
			newvo.setGenerateflag(GenerateFlagEnum.NOGENERATE.getGenerateFlag());
			BaseDAO dao = new BaseDAO();
			dao.updateVO(newvo);
			return ret;
		}
	}

	public InformerAppendVO reGenerateBill(InformerVO vo) throws BusinessException {
		InformerAppendVO ret = new InformerAppendVO();
		InformerVO newvo = (InformerVO) this.getMDQueryService().queryBillOfVOByPK(InformerVO.class,
				vo.getPk_informer(), false);
		InformerSysFlagUtil.checkInformerOperSysFlag("NCC", new InformerVO[]{vo});
		if (!newvo.getTs().equals(vo.getTs())) {
			ret.setErrorMessage(NCLangRes4VoTransl.getNCLangRes().getStrByID("3607inf_0", "03607inf-0088"));
			return ret;
		} else if (!GenerateFlagEnum.NOGENERATE.getGenerateFlag().equals(newvo.getGenerateflag())) {
			ret.setErrorMessage(NCLangRes4VoTransl.getNCLangRes().getStrByID("3607inf_0", "03607inf-0102"));
			return ret;
		} else {
			newvo.setGenerateflag(GenerateFlagEnum.HASNOGENERATE.getGenerateFlag());
			BaseDAO dao = new BaseDAO();
			dao.updateVO(newvo);
			return ret;
		}
	}

	public void updatervo(InformerVO rvo, ISuperVO vo) throws BusinessException {
		rvo.setPk_lower(vo.getPrimaryKey());
		String billtype = (String) vo.getAttributeValue("pk_billtype");
		if (null == billtype) {
			billtype = (String) vo.getAttributeValue("pk_billtypecode");
		}

		if (null == billtype) {
			billtype = (String) vo.getAttributeValue("bill_type");
		}

		rvo.setUsemoney(rvo.getMoneyy());
		rvo.setPk_org((String) vo.getAttributeValue("pk_org"));
		rvo.setPk_org_v((String) vo.getAttributeValue("pk_org_v"));
		rvo.setLowerbilltype(billtype);
		rvo.setGenerateflag(GenerateFlagEnum.HASGENERATE.getGenerateFlag());
		rvo.setStatus(1);
		BaseDAO dao = new BaseDAO();
		dao.updateVO(rvo);
	}

	public InformerAppendVO cancelMakeBill(InformerVO vo) throws BusinessException {
		InformerAppendVO ret = this.validateCancelData(vo);
		if (ret.getErrorMessage() != null) {
			return ret;
		} else {
			String billtype = vo.getLowerbilltype();
			String pk_lower = vo.getPk_lower();
			modifier = vo.getModifier();
			if ("36J7".equals(billtype)) {
				this.updateInformerNoGenerate(vo.getPk_lower());
				this.getCommisionGatherService().cancelGenerateGather(pk_lower);
				return ret;
			} else if ("36J5".equals(billtype)) {
				this.updateInformerNoGenerate(vo.getPk_lower());
				this.getCommisionPayService().cancelGeneratePayment(pk_lower);
				return ret;
			} else if ("36K4".equals(billtype)) {
				this.updateInformerNoGenerate(pk_lower);
				this.getDeliveryService().cancelGenerateDeliveryForInform(pk_lower);
				return ret;
			} else if ("36K2".equals(billtype)) {
				this.updateInformerNoGenerate(pk_lower);
				this.getAllocateService().cancelGenerateAllocate(pk_lower);
				return ret;
			} else if ("F4".equals(billtype)) {
				this.updateInformerNoGenerate(pk_lower);
				this.getSJService().deleteInformerBill(new String[]{vo.getPk_lower()});
				return ret;
			} else if ("F5".equals(billtype)) {
				this.updateInformerNoGenerate(pk_lower);
				this.getFJService().deleteInformerBill(new String[]{vo.getPk_lower()});
				return ret;
			} else if ("F6".equals(billtype)) {
				this.updateInformerNoGenerate(pk_lower);
				this.getHJService().deleteInformerBill(new String[]{vo.getPk_lower()});
				return ret;
			} else if ("F3".equals(billtype)) {
				this.updateInformerNoGenerate(pk_lower);
				this.getFKService().deleteBillBySourcePK(new String[]{vo.getPk_informer()});
				return ret;
			} else if ("F2".equals(billtype)) {
				this.updateInformerNoGenerate(pk_lower);
				this.getSKService().deleteBillBySourcePK(new String[]{vo.getPk_informer()});
				return ret;
			} else if ("36S4".equals(billtype)) {
				this.updateInformerNoGenerate(vo.getPk_lower());
				this.getNewHJService().deleteBills(new String[]{vo.getPk_lower()});
				return ret;
			} else if ("36Z3".equals(billtype)) {
				this.updateInformerNoGenerate(vo.getPk_lower());
				this.getNewHJService().deleteBills(new String[]{vo.getPk_lower()});
				return ret;
			} else if ("3641".equals(billtype)) {
				this.updateInformerNoGenerate(vo.getPk_lower());
				this.getNewHJService().deleteBills(new String[]{vo.getPk_lower()});
				return ret;
			} else if ("3642".equals(billtype)) {
				this.updateInformerNoGenerate(vo.getPk_lower());
				this.getNewHJService().deleteBills(new String[]{vo.getPk_lower()});
				return ret;
			} else if ("36Z4".equals(billtype)) {
				this.updateInformerNoGenerate(vo.getPk_lower());
				this.getNewHJService().deleteBills(new String[]{vo.getPk_lower()});
				return ret;
			} else if ("36Z5".equals(billtype)) {
				this.updateInformerNoGenerate(vo.getPk_lower());
				this.getNewHJService().deleteBills(new String[]{vo.getPk_lower()});
				return ret;
			} 
			else {
				return ret;
			}
		}
	}

	public void updateInformerNoGenerate(String pk_lower) throws BusinessException {
		String sql = " pk_lower = '" + pk_lower + "' and generateflag='hasgenerate' ";
		String excistSql = " select count(*) from cmp_informer where pk_lower = ? and generateflag='hasgenerate'";
		SQLParameter parameter = new SQLParameter();
		parameter.addParam(pk_lower);
		BaseDAO baseDAO = new BaseDAO();
		UFBoolean ifResult = (UFBoolean) baseDAO.executeQuery(excistSql, parameter,
				new IsExistRecordResultSetProcessor());
		if (!UFBoolean.FALSE.equals(ifResult)) {
			Collection<?> result = ((IMDPersistenceQueryService) NCLocator.getInstance()
					.lookup(IMDPersistenceQueryService.class)).queryBillOfVOByCond(InformerVO.class, sql, true, false);
			if (result != null && result.size() != 0) {
				InformerVO[] vos = (InformerVO[]) result.toArray(new InformerVO[0]);
				List<String> pkInformerList = new ArrayList();
				InformerVO[] var10 = vos;
				int var11 = vos.length;

				for (int var12 = 0; var12 < var11; ++var12) {
					InformerVO vo = var10[var12];
					pkInformerList.add(vo.getPk_informer());
				}

				String inPkInformerSql = SqlUtil.buildSqlForIn("pk_informer",
						(String[]) pkInformerList.toArray(new String[0]));
				String sumsql = " select pk_informer,sum(isnull(ly_money,0)) ljlyje from cmp_informerrelease where "
						+ inPkInformerSql + " group by pk_informer ";
				Map<String, String> totoalmap = (Map) baseDAO.executeQuery(sumsql, new MapResultSetProcessor());
				InformerVO[] var21 = vos;
				int var14 = vos.length;

				for (int var15 = 0; var15 < var14; ++var15) {
					InformerVO vo = var21[var15];
					vo.setPk_lower((String) null);
					String usemoney = totoalmap.get(vo.getPk_informer()) == null
							? "0"
							: (String) totoalmap.get(vo.getPk_informer());
					vo.setUsemoney(new UFDouble(usemoney));
					vo.setLowerbilltype((String) null);
					vo.setGenerateflag(this.getGenerateFlag(vo));
					vo.setCreator((String) null);
					vo.setCreationtime((UFDateTime) null);
				}

				BaseDAO dao = new BaseDAO();
				dao.updateVOArray(vos);
			}
		}
	}

	public void updateInformerNoGenerateOut(String pk_lower) throws BusinessException {
		String sql = " pk_lower = '" + pk_lower + "' and generateflag='hasgenerate' ";
		String excistSqlInform = " select count(*) from cmp_informer where pk_lower = ? and generateflag='hasgenerate'";
		String excistSqlRelease = " select count(*) from cmp_informerrelease where pk_lower = ? and generateflag='hasgenerate'";
		SQLParameter parameter = new SQLParameter();
		parameter.addParam(pk_lower);
		BaseDAO baseDAO = new BaseDAO();
		UFBoolean ifResult = (UFBoolean) baseDAO.executeQuery(excistSqlInform, parameter,
				new IsExistRecordResultSetProcessor());
		int var13;
		if (UFBoolean.TRUE.equals(ifResult)) {
			Collection<?> result = ((IMDPersistenceQueryService) NCLocator.getInstance()
					.lookup(IMDPersistenceQueryService.class)).queryBillOfVOByCond(InformerVO.class, sql, true, false);
			if (result == null || result.size() == 0) {
				return;
			}

			InformerVO[] vos = (InformerVO[]) result.toArray(new InformerVO[0]);
			List<String> pkInformerList = new ArrayList();
			InformerVO[] var11 = vos;
			int var12 = vos.length;

			for (var13 = 0; var13 < var12; ++var13) {
				InformerVO vo = var11[var13];
				pkInformerList.add(vo.getPk_informer());
			}

			String inPkInformerSql = SqlUtil.buildSqlForIn("pk_informer",
					(String[]) pkInformerList.toArray(new String[0]));
			String sumsql = " select pk_informer,sum(isnull(ly_money,0)) ljlyje from cmp_informerrelease where "
					+ inPkInformerSql + " group by pk_informer ";
			Map<String, String> totoalmap = (Map) baseDAO.executeQuery(sumsql, new MapResultSetProcessor());
			InformerVO[] var27 = vos;
			int var15 = vos.length;

			for (int var16 = 0; var16 < var15; ++var16) {
				InformerVO vo = var27[var16];
				vo.setPk_lower((String) null);
				String usemoney = totoalmap.get(vo.getPk_informer()) == null
						? "0"
						: (String) totoalmap.get(vo.getPk_informer());
				vo.setUsemoney(new UFDouble(usemoney));
				vo.setLowerbilltype((String) null);
				vo.setGenerateflag(this.getGenerateFlag(vo));
				vo.setCreator((String) null);
				vo.setCreationtime((UFDateTime) null);
			}

			baseDAO.updateVOArray(vos);
		} else {
			SQLParameter releaseparameter = new SQLParameter();
			releaseparameter.addParam(pk_lower);
			UFBoolean isexist = (UFBoolean) baseDAO.executeQuery(excistSqlRelease, parameter,
					new IsExistRecordResultSetProcessor());
			if (UFBoolean.TRUE.equals(isexist)) {
				Collection<?> releasevos = ((IMDPersistenceQueryService) NCLocator.getInstance()
						.lookup(IMDPersistenceQueryService.class)).queryBillOfVOByCond(InformerReleaseVO.class, sql,
								true, false);
				if (releasevos == null || releasevos.size() == 0) {
					return;
				}

				InformerReleaseVO[] vos = (InformerReleaseVO[]) releasevos.toArray(new InformerReleaseVO[0]);
				InformerReleaseVO[] var25 = vos;
				var13 = vos.length;

				for (int var28 = 0; var28 < var13; ++var28) {
					InformerReleaseVO vo = var25[var28];
					vo.setPk_lower((String) null);
					vo.setLowerbilltype((String) null);
					vo.setCreator((String) null);
					vo.setCreationtime((UFDateTime) null);
					vo.setGenerateflag(GenerateFlagEnum.HASCLAIM.getGenerateFlag());
				}

				baseDAO.updateVOArray(vos);
			}
		}

	}

	private void updatervo(InformerVO vo) throws BusinessException {
		vo.setPk_lower((String) null);
		vo.setLowerbilltype((String) null);
		vo.setGenerateflag(this.getGenerateFlag(vo));
		BaseDAO dao = new BaseDAO();
		dao.updateVO(vo);
	}

	public boolean isRelease(InformerVO vo) throws BusinessException {
		String excistRelaseSql = " select count(*) from cmp_informerrelease where pk_informer = ? ";
		BaseDAO baseDAO = new BaseDAO();
		SQLParameter pk_informparam = new SQLParameter();
		pk_informparam.addParam(vo.getPk_informer());
		UFBoolean isrelse = (UFBoolean) baseDAO.executeQuery(excistRelaseSql, pk_informparam,
				new IsExistRecordResultSetProcessor());
		return isrelse.booleanValue();
	}

	public String getGenerateFlag(InformerVO vo) throws BusinessException {
		if (vo.getUsemoney() != null && vo.getUsemoney().compareTo(UFDouble.ZERO_DBL) > 0) {
			return GenerateFlagEnum.HASRELEASE.getGenerateFlag();
		} else {
			return this.isRelease(vo)
					? GenerateFlagEnum.HASRELEASE.getGenerateFlag()
					: GenerateFlagEnum.HASNOGENERATE.getGenerateFlag();
		}
	}

	private InformerAppendVO validateCancelData(InformerVO rvo) throws BusinessException {
		InformerAppendVO dvo = new InformerAppendVO();
		InformerVO newvo = (InformerVO) this.getMDQueryService().queryBillOfVOByPK(InformerVO.class,
				rvo.getPk_informer(), false);
		if (!newvo.getTs().equals(rvo.getTs()) && !rvo.getModifier().equals(newvo.getModifier())) {
			dvo.setErrorMessage(NCLangRes4VoTransl.getNCLangRes().getStrByID("3607inf_0", "03607inf-0088"));
			return dvo;
		} else if (GenerateFlagEnum.HASNOGENERATE.getGenerateFlag().equals(rvo.getGenerateflag())) {
			dvo.setErrorMessage(NCLangRes4VoTransl.getNCLangRes().getStrByID("3607inf_0", "03607inf-0096"));
			return dvo;
		} else if (GenerateFlagEnum.NOGENERATE.getGenerateFlag().equals(newvo.getGenerateflag())) {
			dvo.setErrorMessage(NCLangRes4VoTransl.getNCLangRes().getStrByID("3607inf_0", "03607inf-0097"));
			return dvo;
		} else if (rvo.getPk_lower() != null && rvo.getLowerbilltype() != null) {
			if (!"36J7".equals(rvo.getLowerbilltype()) && !"36J5".equals(rvo.getLowerbilltype())
					&& !"36K4".equals(rvo.getLowerbilltype()) && !"36K2".equals(rvo.getLowerbilltype())
					&& !"F4".equals(rvo.getLowerbilltype()) && !"F5".equals(rvo.getLowerbilltype())
					&& !"F6".equals(rvo.getLowerbilltype()) && !"36S4".equals(rvo.getLowerbilltype())
					&& !"F3".equals(rvo.getLowerbilltype()) && !"F2".equals(rvo.getLowerbilltype())
					&& !"36Z3".equals(rvo.getLowerbilltype())&& !"3641".equals(rvo.getLowerbilltype())
					&& !"3642".equals(rvo.getLowerbilltype())&& !"36Z4".equals(rvo.getLowerbilltype())
					&& !"36Z5".equals(rvo.getLowerbilltype())) {
				dvo.setErrorMessage(NCLangRes4VoTransl.getNCLangRes().getStrByID("3607inf_0", "03607inf-0101",
						(String) null, new String[]{rvo.getLowerbilltype()}));
				return dvo;
			} else {
				return dvo;
			}
		} else {
			dvo.setErrorMessage(NCLangRes4VoTransl.getNCLangRes().getStrByID("3607inf_0", "03607inf-0098",
					(String) null, new String[]{rvo.getPk_lower(), rvo.getLowerbilltype()}));
			return dvo;
		}
	}

	public void validateCommonData(InformerVO rvo, InformerAppendVO dvo) throws BusinessException {
		if (null == rvo) {
			dvo.setErrorMessage(NCLangRes4VoTransl.getNCLangRes().getStrByID("3607inf_0", "03607inf-0087"));
		} else {
			if (rvo.getRowno() != null) {
				dvo.setRowNO(rvo.getRowno());
			} else {
				dvo.setRowNO(1);
			}

			InformerVO newvo = (InformerVO) this.getMDQueryService().queryBillOfVOByPK(InformerVO.class,
					rvo.getPk_informer(), false);
			if (!newvo.getTs().equals(rvo.getTs())) {
				dvo.setErrorMessage(NCLangRes4VoTransl.getNCLangRes().getStrByID("3607inf_0", "03607inf-0088"));
			} else if (GenerateFlagEnum.HASGENERATE.getGenerateFlag().equals(newvo.getGenerateflag())) {
				dvo.setErrorMessage(NCLangRes4VoTransl.getNCLangRes().getStrByID("3607informercmp_ncc_0",
						"03607informercmp_ncc-0024"));
			} else if (GenerateFlagEnum.NOGENERATE.getGenerateFlag().equals(newvo.getGenerateflag())) {
				dvo.setErrorMessage(NCLangRes4VoTransl.getNCLangRes().getStrByID("3607inf_0", "03607inf-0090"));
			} else {
				if (newvo.getMoneyy()
						.compareTo(newvo.getUsemoney() == null ? UFDouble.ZERO_DBL : newvo.getUsemoney()) <= 0) {
					dvo.setErrorMessage(NCLangRes4VoTransl.getNCLangRes().getStrByID("3607informercmp_ncc_0",
							"03607informercmp_ncc-0025") + rvo.getVbillno());
				}

			}
		}
	}

	public Map<String, InformerAppendVO> validateCommonData(InformerVO[] rvos, InformerAppendVO informerAppendVO)
			throws BusinessException {
		Map<String, InformerAppendVO> informerAppendVOs = new HashMap();
		String[] pks = new String[rvos.length];

		for (int i = 0; i < rvos.length; ++i) {
			pks[i] = rvos[i].getPk_informer();
		}

		Collection<InformerVO> newvos = this.getMDQueryService().queryBillOfVOByPKs(InformerVO.class, pks, false);
		Map<String, InformerVO> informerVOs = new HashMap();
		Iterator var7 = newvos.iterator();

		while (var7.hasNext()) {
			InformerVO informerVO = (InformerVO) var7.next();
			informerVOs.put(informerVO.getPrimaryKey(), informerVO);
		}

		InformerVO[] var14 = rvos;
		int var15 = rvos.length;

		for (int var9 = 0; var9 < var15; ++var9) {
			InformerVO rvo = var14[var9];
			InformerAppendVO dvo = informerAppendVO.clone();
			InformerVO newvo = (InformerVO) informerVOs.get(rvo.getPrimaryKey());
			if (null == rvos) {
				dvo.setErrorMessage(NCLangRes4VoTransl.getNCLangRes().getStrByID("3607inf_0", "03607inf-0087"));
			}

			if (!newvo.getTs().equals(rvo.getTs())) {
				dvo.setErrorMessage(NCLangRes4VoTransl.getNCLangRes().getStrByID("3607inf_0", "03607inf-0088"));
			}

			if (GenerateFlagEnum.HASGENERATE.getGenerateFlag().equals(newvo.getGenerateflag())) {
				dvo.setErrorMessage(NCLangRes4VoTransl.getNCLangRes().getStrByID("3607inf_0", "03607inf-0123",
						(String) null, new String[]{rvo.getVbillno()}));
			}

			if (GenerateFlagEnum.NOGENERATE.getGenerateFlag().equals(newvo.getGenerateflag())) {
				dvo.setErrorMessage(NCLangRes4VoTransl.getNCLangRes().getStrByID("3607inf_0", "03607inf-0090"));
			}

			informerAppendVOs.put(rvo.getPrimaryKey(), dvo);
		}

		return informerAppendVOs;
	}

	public void validateCommisionData(InformerAppendVO dvo, InformerVO rvo) throws BusinessException {
		if (rvo.getPk_org() == null) {
			dvo.setErrorMessage(NCLangRes4VoTransl.getNCLangRes().getStrByID("3607inf_0", "03607inf-0085"));
		} else if (!this.isFundOrg(rvo.getPk_org())) {
			dvo.setErrorMessage(NCLangRes4VoTransl.getNCLangRes().getStrByID("3607inf_0", "03607inf-0086"));
		}
	}

	private boolean isFundOrg(String pk_org) throws BusinessException {
		return this.getFundOrgService().isFundOrg(pk_org);
	}

	public void validateFundOrg(InformerVO rvo, InformerAppendVO dvo) throws BusinessException {
		String pk_currFundOrg = rvo.getPk_org();
		String pk_fundOrg = dvo.getPk_FundOrg();
		if (!pk_currFundOrg.equals(pk_fundOrg)) {
			HashMap<String, ArrayList<FundOrgVO>> fundOrgsMap = this.getFundOrgService()
					.querySameFatherFundOrgPathMapByFundOrgIDS(pk_currFundOrg, pk_fundOrg);
			if (fundOrgsMap == null) {
				throw new BusinessException(
						NCLangRes4VoTransl.getNCLangRes().getStrByID("3607inf1_0", "03607inf1-0055"));
			} else {
				Iterator var6 = ((ArrayList) fundOrgsMap.get(pk_currFundOrg)).iterator();

				FundOrgVO fundOrgVO;
				while (var6.hasNext()) {
					fundOrgVO = (FundOrgVO) var6.next();
					if (pk_fundOrg.equals(fundOrgVO.getPk_fatherorg())
							&& fundOrgVO.getPrimaryKey().equals(pk_currFundOrg)) {
						return;
					}

					if (pk_fundOrg.equals(fundOrgVO.getPk_fatherorg())) {
						break;
					}
				}

				var6 = ((ArrayList) fundOrgsMap.get(pk_fundOrg)).iterator();

				while (var6.hasNext()) {
					fundOrgVO = (FundOrgVO) var6.next();
					if (pk_currFundOrg.equals(fundOrgVO.getPk_fatherorg())
							&& fundOrgVO.getPrimaryKey().equals(pk_fundOrg)) {
						return;
					}

					if (pk_currFundOrg.equals(fundOrgVO.getPk_fatherorg())) {
						break;
					}
				}

				if (dvo.getPk_FinanceOrg() == null) {
					throw new BusinessException(
							NCLangRes4VoTransl.getNCLangRes().getStrByID("3607inf1_0", "03607inf1-0056"));
				} else if (dvo.getPk_accid() == null) {
					throw new BusinessException(
							NCLangRes4VoTransl.getNCLangRes().getStrByID("3607inf1_0", "03607inf1-0057"));
				}
			}
		}
	}

	public void validateProcessDate(InformerVO rvo, InformerAppendVO dvo, String moduleID) throws BusinessException {
		DateManageQueryVO queryVO = new DateManageQueryVO();
		queryVO.setCurrentBusiDate(rvo.getInfodate());
		if (!StringUtil.isNull(rvo.getPk_group())) {
			queryVO.setPk_group(rvo.getPk_group());
		} else {
			queryVO.setPk_group(AppContext.getInstance().getPkGroup());
		}

		queryVO.setPk_org(rvo.getPk_org());
		queryVO.setMaxBillDate((UFDate) null);
		queryVO.setDateName(NCLangRes4VoTransl.getNCLangRes().getStrByID("3607inf_0", "03607inf-0115"));
		UFDate busiDate = AppContext.getInstance().getBusiDate();
		String result = CommInitDateCheck.checkInitDate(busiDate, rvo.getPk_org(), moduleID);
		if (!StringUtil.isNull(result)) {
			dvo.setErrorMessage(result);
		}
	}

	private IFundOrgPubService getFundOrgService() {
		return (IFundOrgPubService) NCLocator.getInstance().lookup(IFundOrgPubService.class);
	}

	public IMDPersistenceQueryService getMDQueryService() {
		if (this.mdQueryService == null) {
			this.mdQueryService = (IMDPersistenceQueryService) NCLocator.getInstance()
					.lookup(IMDPersistenceQueryService.class);
		}

		return this.mdQueryService;
	}

	public IAllocateForInformerService getAllocateService() {
		return (IAllocateForInformerService) NCLocator.getInstance().lookup(IAllocateForInformerService.class);
	}

	public IDeliveryForInformerService getDeliveryService() {
		return (IDeliveryForInformerService) NCLocator.getInstance().lookup(IDeliveryForInformerService.class);
	}

	public ICommissionGatherForInformerService getCommisionGatherService() {
		return (ICommissionGatherForInformerService) NCLocator.getInstance()
				.lookup(ICommissionGatherForInformerService.class);
	}

	public ICommissionPaymentForInformerService getCommisionPayService() {
		return (ICommissionPaymentForInformerService) NCLocator.getInstance()
				.lookup(ICommissionPaymentForInformerService.class);
	}

	public ICmpRecBillPubService getSJService() {
		return (ICmpRecBillPubService) NCLocator.getInstance().lookup(ICmpRecBillPubService.class);
	}

	public ICmpPayBillPubService getFJService() {
		return (ICmpPayBillPubService) NCLocator.getInstance().lookup(ICmpPayBillPubService.class);
	}

	@Deprecated
	public ICmpChangeBillPubService getHJService() {
		return (ICmpChangeBillPubService) NCLocator.getInstance().lookup(ICmpChangeBillPubService.class);
	}

	public ITransformBillMaintainService getNewHJService() {
		return (ITransformBillMaintainService) NCLocator.getInstance().lookup(ITransformBillMaintainService.class);
	}

	public IArapPayBillPubService getFKService() {
		return (IArapPayBillPubService) NCLocator.getInstance().lookup(IArapPayBillPubService.class);
	}

	public IArapGatheringBillPubService getSKService() {
		return (IArapGatheringBillPubService) NCLocator.getInstance().lookup(IArapGatheringBillPubService.class);
	}
}